package com.ashin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Ashin
 * @Date: 2021/5/10
 * @Description: com.ashin.controller
 * @Version: 1.0.0
 */
@RestController
public class HelloRedisController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping("/publish/{topic}")
    public String publish(@PathVariable String topic) {
        for (int i = 1; i <= 10; i++) {
            stringRedisTemplate.convertAndSend(topic, "这是我发第" + i + "条的消息啊");
        }
        return "结束";
    }


    @RequestMapping("/unsub/{topic}")
    public String unsubscribe(@PathVariable String topic) {

        return "结束";
    }




}
